<style>
.bType {
	color: #289be5 !important;;
}

.share {
	color: #e9573f !important;;
}

.treeComplete {
	overflow: hidden;
}
</style>
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<div class="pageContent treeComplete">
	<input id="selectType" type="hidden" value="${selectType!''}"> <input id="selectNode" type="hidden" value="${selectNode!''}"> <input type="hidden" name="navTabId" id="navTabId" value="${navTabId!''}">
	<div>
		<div class="treeleft">
			<div class="mini-toolbar">
				<input type="text" id="search" /> <a class="buttonActive" href="javascript:void(0)" id="searchTree"><span><@label key='search.B'>搜索</@label></span></a>
			</div>
			<div id="menuBar" class="pBar pBarBorder">
				<ul class="toolBar">
					<li><a class="collapse" id="collapsable" title="<@label key="collapseAll.D">全部收起</@label>"><span><@label key="collapse.B">收起</@label></span>
					</a></li>
					<li><a class="expand" id="expandable" title="<@label key="expandAll.D">全部展开</@label>"><span><@label key="expand.B">展开</@label></span>
					</a></li> <@buttonRight menuCode="CUSTOMQUERY_DEL" labelKey="delete.B" defalutName="删除">
					<li><a id="deleteQuery" class="delete" href="javascript:void(0);" title="<@label key='delete.B'>删除</@label>"><span><@label key="delete.B">删除</@label></span> </a></li> </@buttonRight> <@buttonRight menuCode="CUSTOMQUERY_RENAME" labelKey="rename.B" defalutName="重命名">
					<li><a id="renameQuery" class="edit" href="javascript:void(0);" title="<@label key='rename.B'>重命名</@label>"><span><@label key="rename.B">重命名</@label></span> </a></li> </@buttonRight>
				</ul>
			</div>

			<div layoutH="70" class="treebody">
				<ul id="tree" class="tree treeFolder expand">
					<#list types as type>
					<li><a target="ajax" rel="queryDetail" class="bType" tvalue="${type.businessType}" href="${rc.getContextPath()}/manage/customQuery/newCustomQuery?type=${type.businessType}&navTabId=${navTabId!''}">${type.businessTypeText}</a> <#if type.querys?? &&type.querys?size gt 0>
						<ul>
							<#list type.querys as query>
							<li><a  rel="queryDetail" class="queryLink <#if query.otherOwner==1>share<#else>cQuery</#if>" tvalue="${type.businessType}_${query.screenName}" screenName="${query.screenName}" businessType="${type.businessType}" createUser="${query.createUser}"> ${query.screenName}<#if query.otherOwner==1>(${query.createUser})</#if> </a></li> </#list>
						</ul> </#if></li> </#list>
				</ul>
			</div>

		</div>
		<div id="queryDetail" class="unitBox treeBox" style="position: relative; padding: 0 0 0 1px;">
			<div class="treeTip"><@label key="treeTips.M">请点击左侧树形菜单进行相关操作</@label></div>
		</div>

	</div>

</div>

<div style="display: none">
	<div id="openWindows">
		<div class="pageContent">
			<div class="pageFormContent">
				<fieldset>
					<dl class="nowrap">
						<dt style="width: 50px;"><@label key="name.C,colon">名称：</@label></dt>
						<dd>
							<input class="required" id="newName" value="" type="text" maxlength="30" />
						</dd>
					</dl>
				</fieldset>
			</div>
			<div class="formBar">
				<ul>
					<li><div class="buttonActive" id="save">
							<div class="buttonContent">
								<button type="button" id="dialogOk"><@label key="ok.B">确定</@label></button>
							</div>
						</div></li>
					<li>
						<div class="buttonActiveGrey">
							<div class="buttonContent">
								<button type="button" id="dialogClose"><@label key="cancel.B">取消</@label></button>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	(function() {
		$(function() {
			var $page = navTab.getCurrentPanel();
			$('#deleteQuery', $page).hide();
			$('#renameQuery', $page).hide();
			$("#searchTree", $page).baseTreeSearch({
				inputTextId: "#search", //搜索框的id
				alertMsg: "<@label key='Tree_search_Input.D'>输入名称进行查询</@label>", //提示内容，要考虑国际化，传自后台
				$p: navTab.getCurrentPanel()
			});
			$("#collapsable", $page)._treeCollapsable({
				$p: navTab.getCurrentPanel()
			});

			$("#expandable", $page)._treeExpandable({
				$p: navTab.getCurrentPanel()
			});
			$('.treeComplete', $page).on('treeComplete', function() {
				var selectNode = $("#selectNode", $page).val();
				var selectType = $("#selectType", $page).val();
				if (selectNode) {
					$(this)._searchByValue({
						searchValue: selectType + "_" + selectNode,
						$p: navTab.getCurrentPanel()
					});
				}
			});

			$('.bType', $page).on('click', function() {
				$('#deleteQuery', $page).hide();
				$('#renameQuery', $page).hide();
			});

			$('.cQuery', $page).on('click', function() {
				$('#deleteQuery', $page).show();
				$('#renameQuery', $page).show();
			});

			$('.queryLink', $page).on('click', function(event) {
				var $this = $(this);
				var businessType = $this.attr('businessType');
				var screenName = $this.attr('screenName');
				var createUser = $this.attr('createUser');
				var rel = $this.attr("rel");
				var url="${rc.getContextPath()}/manage/customQuery/editCustomQuery";
				if (rel) {
					var $rel = $("#"+rel, $page);
					$rel.loadUrl(url, {
						type:businessType,
						screenName:screenName,
						navTabId:$('#navTabId', $page).val(),
						createUser:createUser
					}, function(){
						$rel.find("[layoutH]").layoutH();
					});
				}
				event.preventDefault();
				return false;
			});

			$('#deleteQuery', $page).click(function() {
				var $a = $('#tree div.selected>a', $page);
				var businessType = $a.attr('businessType');
				var screenName = $a.attr('screenName');
				var createUser = $a.attr('createUser');
				alertMsg.confirm("<@label key='confirmDelQuery.M'>确认要删除当前选择的自定义查询吗？</@label>", {
					okCall: function() {
						DWZ.ajax({
							type: 'POST',
							url: 'customQuery/deleteQuery',
							data: {
								"businessType": businessType,
								"screenName": screenName,
								"createUser": createUser,
								"navTabId": $('#navTabId', $page).val()
							},
							dataType: "json",
							cache: false,
							success: function(data) {
								navTabAjaxDone(data);
							}
						});
					}
				});

			});

			$('#renameQuery', $page).click(function() {
				var $a = $('#tree div.selected>a', $page);
				var businessType = $a.attr('businessType');
				var screenName = $a.attr('screenName');
				var createUser = $a.attr('createUser');
				var $dialogClone = $("#openWindows", $page).clone(true);
				$.pdialog.open('', "editName", "<@label key='rename.B'>重命名</@label>", {
					mask: true,
					width: 320,
					height: 130,
					maxable: false,
					minable: false,
					callback: function(dialogContent) {
						dialogContent.append($dialogClone);
						$('#dialogClose', $dialogClone).click(function() {
							$.pdialog.close("editName");
						});
						$('#dialogOk', $dialogClone).click(function() {
							DWZ.ajax({
								type: 'POST',
								url: 'customQuery/renameQuery',
								data: {
									"businessType": businessType,
									"newName": $('#newName', $dialogClone).val(),
									"screenName": screenName,
									"createUser": createUser,
									"navTabId": $('#navTabId', $page).val()
								},
								dataType: "json",
								cache: false,
								success: function(data) {
									$.pdialog.close("editName");
									navTabAjaxDone(data);
								}
							});
						});
					}
				});
			});

		});
	})(jQuery);
</script>